package com.gyp.controller.login;

import com.gyp.exception.BusinessException;
import com.gyp.manager.PersonManager;
import com.gyp.model.common.Result;
import com.gyp.service.UserService;
import com.gyp.utils.JSONUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;




@RequestMapping("/file")
@Slf4j
@Validated
@RestController
@Api(tags = "文件相关")
public class FileController {


    @Autowired
    public UserService userService;

    @Autowired
    public PersonManager personManager;




    @ApiOperation("文件上传[提供给用户端使用][免鉴权]")
    @PostMapping("/upload/noAuth")
    public Result<String> uploadCommonNoAuthFile(@RequestParam("file") MultipartFile file) {
        if (file.isEmpty()) {
            throw new BusinessException("10057");
        }
        String signUrl = userService.upload(file);
        return Result.data(signUrl);
    }




}
